﻿using System;
using System.Collections.Generic;
using System.Text;
using MySql.Data.MySqlClient;
using NetTao.Model;

namespace NetTao.Dao
{
    public class DaoArticle:DaoBase
    {
        public DaoArticle(string connectionString)
            : base(connectionString)
        {
            ConnectionString = connectionString;
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(NetTao.Model.ArticleInfo model)
        {
            var strSql = new StringBuilder();
            strSql.Append("insert into jieqi_article_article(");
            strSql.Append("siteid,postdate,lastupdate,articlename,keywords,initial,authorid,author,posterid,poster,agentid,agent,sortid,typeid,intro,notice,setting,lastvolumeid,lastvolume,lastchapterid,lastchapter,chapters,size,lastvisit,dayvisit,weekvisit,monthvisit,allvisit,lastvote,dayvote,weekvote,monthvote,allvote,vipvotetime,vipvotenow,vipvotepreview,goodnum,badnum,toptime,saleprice,salenum,totalcost,articletype,permission,firstflag,fullflag,imgflag,power,display,articleid)");
            strSql.Append(" values (");
            strSql.Append("?siteid,?postdate,?lastupdate,?articlename,?keywords,?initial,?authorid,?author,?posterid,?poster,?agentid,?agent,?sortid,?typeid,?intro,?notice,?setting,?lastvolumeid,?lastvolume,?lastchapterid,?lastchapter,?chapters,?size,?lastvisit,?dayvisit,?weekvisit,?monthvisit,?allvisit,?lastvote,?dayvote,?weekvote,?monthvote,?allvote,?vipvotetime,?vipvotenow,?vipvotepreview,?goodnum,?badnum,?toptime,?saleprice,?salenum,?totalcost,?articletype,?permission,?firstflag,?fullflag,?imgflag,?power,?display,?articleid)");
            MySqlParameter[] parameters = {
					new MySqlParameter("?siteid", MySqlDbType.Int16,6),
					new MySqlParameter("?postdate", MySqlDbType.Int32,11),
					new MySqlParameter("?lastupdate", MySqlDbType.Int32,11),
					new MySqlParameter("?articlename", MySqlDbType.VarChar,50),
					new MySqlParameter("?keywords", MySqlDbType.VarChar,50),
					new MySqlParameter("?initial", MySqlDbType.VarChar,1),
					new MySqlParameter("?authorid", MySqlDbType.Int32,11),
					new MySqlParameter("?author", MySqlDbType.VarChar,30),
					new MySqlParameter("?posterid", MySqlDbType.Int32,11),
					new MySqlParameter("?poster", MySqlDbType.VarChar,30),
					new MySqlParameter("?agentid", MySqlDbType.Int32,11),
					new MySqlParameter("?agent", MySqlDbType.VarChar,30),
					new MySqlParameter("?sortid", MySqlDbType.Int16,3),
					new MySqlParameter("?typeid", MySqlDbType.Int16,3),
					new MySqlParameter("?intro", MySqlDbType.Text),
					new MySqlParameter("?notice", MySqlDbType.Text),
					new MySqlParameter("?setting", MySqlDbType.Text),
					new MySqlParameter("?lastvolumeid", MySqlDbType.Int32,11),
					new MySqlParameter("?lastvolume", MySqlDbType.VarChar,100),
					new MySqlParameter("?lastchapterid", MySqlDbType.Int32,11),
					new MySqlParameter("?lastchapter", MySqlDbType.VarChar,100),
					new MySqlParameter("?chapters", MySqlDbType.Int16,6),
					new MySqlParameter("?size", MySqlDbType.Int32,11),
					new MySqlParameter("?lastvisit", MySqlDbType.Int32,11),
					new MySqlParameter("?dayvisit", MySqlDbType.Int32,11),
					new MySqlParameter("?weekvisit", MySqlDbType.Int32,11),
					new MySqlParameter("?monthvisit", MySqlDbType.Int32,11),
					new MySqlParameter("?allvisit", MySqlDbType.Int32,11),
					new MySqlParameter("?lastvote", MySqlDbType.Int32,11),
					new MySqlParameter("?dayvote", MySqlDbType.Int32,11),
					new MySqlParameter("?weekvote", MySqlDbType.Int32,11),
					new MySqlParameter("?monthvote", MySqlDbType.Int32,11),
					new MySqlParameter("?allvote", MySqlDbType.Int32,11),
					new MySqlParameter("?vipvotetime", MySqlDbType.Int32,11),
					new MySqlParameter("?vipvotenow", MySqlDbType.Int32,11),
					new MySqlParameter("?vipvotepreview", MySqlDbType.Int32,11),
					new MySqlParameter("?goodnum", MySqlDbType.Int32,11),
					new MySqlParameter("?badnum", MySqlDbType.Int32,11),
					new MySqlParameter("?toptime", MySqlDbType.Int32,11),
					new MySqlParameter("?saleprice", MySqlDbType.Int32,11),
					new MySqlParameter("?salenum", MySqlDbType.Int32,11),
					new MySqlParameter("?totalcost", MySqlDbType.Int32,11),
					new MySqlParameter("?articletype", MySqlDbType.Int16,1),
					new MySqlParameter("?permission", MySqlDbType.Int16,1),
					new MySqlParameter("?firstflag", MySqlDbType.Int16,1),
					new MySqlParameter("?fullflag", MySqlDbType.Int16,1),
					new MySqlParameter("?imgflag", MySqlDbType.Int16,1),
					new MySqlParameter("?power", MySqlDbType.Int16,1),
					new MySqlParameter("?display", MySqlDbType.Int16,1),
                    new MySqlParameter("?articleid", MySqlDbType.Int32,11)};
            parameters[0].Value = model.siteid;
            parameters[1].Value = model.postdate;
            parameters[2].Value = model.lastupdate;
            parameters[3].Value = model.articlename;
            parameters[4].Value = model.keywords;
            parameters[5].Value = model.initial;
            parameters[6].Value = model.authorid;
            parameters[7].Value = model.author;
            parameters[8].Value = model.posterid;
            parameters[9].Value = model.poster;
            parameters[10].Value = model.agentid;
            parameters[11].Value = model.agent;
            parameters[12].Value = model.sortid;
            parameters[13].Value = model.typeid;
            parameters[14].Value = model.intro;
            parameters[15].Value = model.notice;
            parameters[16].Value = model.setting;
            parameters[17].Value = model.lastvolumeid;
            parameters[18].Value = model.lastvolume;
            parameters[19].Value = model.lastchapterid;
            parameters[20].Value = model.lastchapter;
            parameters[21].Value = model.chapters;
            parameters[22].Value = model.size;
            parameters[23].Value = model.lastvisit;
            parameters[24].Value = model.dayvisit;
            parameters[25].Value = model.weekvisit;
            parameters[26].Value = model.monthvisit;
            parameters[27].Value = model.allvisit;
            parameters[28].Value = model.lastvote;
            parameters[29].Value = model.dayvote;
            parameters[30].Value = model.weekvote;
            parameters[31].Value = model.monthvote;
            parameters[32].Value = model.allvote;
            parameters[33].Value = model.vipvotetime;
            parameters[34].Value = model.vipvotenow;
            parameters[35].Value = model.vipvotepreview;
            parameters[36].Value = model.goodnum;
            parameters[37].Value = model.badnum;
            parameters[38].Value = model.toptime;
            parameters[39].Value = model.saleprice;
            parameters[40].Value = model.salenum;
            parameters[41].Value = model.totalcost;
            parameters[42].Value = model.articletype;
            parameters[43].Value = model.permission;
            parameters[44].Value = model.firstflag;
            parameters[45].Value = model.fullflag;
            parameters[46].Value = model.imgflag;
            parameters[47].Value = model.power;
            parameters[48].Value = model.display;
            parameters[49].Value = model.articleid;
            return MySqlHelper.ExecuteNonQuery(Connection, System.Data.CommandType.Text, strSql.ToString(), parameters) >= 0;
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ArticleInfo model)
        {
            var strSql = new StringBuilder();
            strSql.Append("update jieqi_article_article set ");
            strSql.Append("siteid=?siteid,");
            strSql.Append("postdate=?postdate,");
            strSql.Append("lastupdate=?lastupdate,");
            strSql.Append("articlename=?articlename,");
            strSql.Append("keywords=?keywords,");
            strSql.Append("initial=?initial,");
            strSql.Append("authorid=?authorid,");
            strSql.Append("author=?author,");
            strSql.Append("posterid=?posterid,");
            strSql.Append("poster=?poster,");
            strSql.Append("agentid=?agentid,");
            strSql.Append("agent=?agent,");
            strSql.Append("sortid=?sortid,");
            strSql.Append("typeid=?typeid,");
            strSql.Append("intro=?intro,");
            strSql.Append("notice=?notice,");
            strSql.Append("setting=?setting,");
            strSql.Append("lastvolumeid=?lastvolumeid,");
            strSql.Append("lastvolume=?lastvolume,");
            strSql.Append("lastchapterid=?lastchapterid,");
            strSql.Append("lastchapter=?lastchapter,");
            strSql.Append("chapters=?chapters,");
            strSql.Append("size=?size,");
            strSql.Append("lastvisit=?lastvisit,");
            strSql.Append("dayvisit=?dayvisit,");
            strSql.Append("weekvisit=?weekvisit,");
            strSql.Append("monthvisit=?monthvisit,");
            strSql.Append("allvisit=?allvisit,");
            strSql.Append("lastvote=?lastvote,");
            strSql.Append("dayvote=?dayvote,");
            strSql.Append("weekvote=?weekvote,");
            strSql.Append("monthvote=?monthvote,");
            strSql.Append("allvote=?allvote,");
            strSql.Append("vipvotetime=?vipvotetime,");
            strSql.Append("vipvotenow=?vipvotenow,");
            strSql.Append("vipvotepreview=?vipvotepreview,");
            strSql.Append("goodnum=?goodnum,");
            strSql.Append("badnum=?badnum,");
            strSql.Append("toptime=?toptime,");
            strSql.Append("saleprice=?saleprice,");
            strSql.Append("salenum=?salenum,");
            strSql.Append("totalcost=?totalcost,");
            strSql.Append("articletype=?articletype,");
            strSql.Append("permission=?permission,");
            strSql.Append("firstflag=?firstflag,");
            strSql.Append("fullflag=?fullflag,");
            strSql.Append("imgflag=?imgflag,");
            strSql.Append("power=?power,");
            strSql.Append("display=?display");
            strSql.Append(" where articleid=?articleid");
            MySqlParameter[] parameters = {
					new MySqlParameter("?siteid", MySqlDbType.Int16,6),
					new MySqlParameter("?postdate", MySqlDbType.Int32,11),
					new MySqlParameter("?lastupdate", MySqlDbType.Int32,11),
					new MySqlParameter("?articlename", MySqlDbType.VarChar,50),
					new MySqlParameter("?keywords", MySqlDbType.VarChar,50),
					new MySqlParameter("?initial", MySqlDbType.VarChar,1),
					new MySqlParameter("?authorid", MySqlDbType.Int32,11),
					new MySqlParameter("?author", MySqlDbType.VarChar,30),
					new MySqlParameter("?posterid", MySqlDbType.Int32,11),
					new MySqlParameter("?poster", MySqlDbType.VarChar,30),
					new MySqlParameter("?agentid", MySqlDbType.Int32,11),
					new MySqlParameter("?agent", MySqlDbType.VarChar,30),
					new MySqlParameter("?sortid", MySqlDbType.Int16,3),
					new MySqlParameter("?typeid", MySqlDbType.Int16,3),
					new MySqlParameter("?intro", MySqlDbType.Text),
					new MySqlParameter("?notice", MySqlDbType.Text),
					new MySqlParameter("?setting", MySqlDbType.Text),
					new MySqlParameter("?lastvolumeid", MySqlDbType.Int32,11),
					new MySqlParameter("?lastvolume", MySqlDbType.VarChar,100),
					new MySqlParameter("?lastchapterid", MySqlDbType.Int32,11),
					new MySqlParameter("?lastchapter", MySqlDbType.VarChar,100),
					new MySqlParameter("?chapters", MySqlDbType.Int16,6),
					new MySqlParameter("?size", MySqlDbType.Int32,11),
					new MySqlParameter("?lastvisit", MySqlDbType.Int32,11),
					new MySqlParameter("?dayvisit", MySqlDbType.Int32,11),
					new MySqlParameter("?weekvisit", MySqlDbType.Int32,11),
					new MySqlParameter("?monthvisit", MySqlDbType.Int32,11),
					new MySqlParameter("?allvisit", MySqlDbType.Int32,11),
					new MySqlParameter("?lastvote", MySqlDbType.Int32,11),
					new MySqlParameter("?dayvote", MySqlDbType.Int32,11),
					new MySqlParameter("?weekvote", MySqlDbType.Int32,11),
					new MySqlParameter("?monthvote", MySqlDbType.Int32,11),
					new MySqlParameter("?allvote", MySqlDbType.Int32,11),
					new MySqlParameter("?vipvotetime", MySqlDbType.Int32,11),
					new MySqlParameter("?vipvotenow", MySqlDbType.Int32,11),
					new MySqlParameter("?vipvotepreview", MySqlDbType.Int32,11),
					new MySqlParameter("?goodnum", MySqlDbType.Int32,11),
					new MySqlParameter("?badnum", MySqlDbType.Int32,11),
					new MySqlParameter("?toptime", MySqlDbType.Int32,11),
					new MySqlParameter("?saleprice", MySqlDbType.Int32,11),
					new MySqlParameter("?salenum", MySqlDbType.Int32,11),
					new MySqlParameter("?totalcost", MySqlDbType.Int32,11),
					new MySqlParameter("?articletype", MySqlDbType.Int16,1),
					new MySqlParameter("?permission", MySqlDbType.Int16,1),
					new MySqlParameter("?firstflag", MySqlDbType.Int16,1),
					new MySqlParameter("?fullflag", MySqlDbType.Int16,1),
					new MySqlParameter("?imgflag", MySqlDbType.Int16,1),
					new MySqlParameter("?power", MySqlDbType.Int16,1),
					new MySqlParameter("?display", MySqlDbType.Int16,1),
					new MySqlParameter("?articleid", MySqlDbType.Int32,11)};
            parameters[0].Value = model.siteid;
            parameters[1].Value = model.postdate;
            parameters[2].Value = model.lastupdate;
            parameters[3].Value = model.articlename;
            parameters[4].Value = model.keywords;
            parameters[5].Value = model.initial;
            parameters[6].Value = model.authorid;
            parameters[7].Value = model.author;
            parameters[8].Value = model.posterid;
            parameters[9].Value = model.poster;
            parameters[10].Value = model.agentid;
            parameters[11].Value = model.agent;
            parameters[12].Value = model.sortid;
            parameters[13].Value = model.typeid;
            parameters[14].Value = model.intro;
            parameters[15].Value = model.notice;
            parameters[16].Value = model.setting;
            parameters[17].Value = model.lastvolumeid;
            parameters[18].Value = model.lastvolume;
            parameters[19].Value = model.lastchapterid;
            parameters[20].Value = model.lastchapter;
            parameters[21].Value = model.chapters;
            parameters[22].Value = model.size;
            parameters[23].Value = model.lastvisit;
            parameters[24].Value = model.dayvisit;
            parameters[25].Value = model.weekvisit;
            parameters[26].Value = model.monthvisit;
            parameters[27].Value = model.allvisit;
            parameters[28].Value = model.lastvote;
            parameters[29].Value = model.dayvote;
            parameters[30].Value = model.weekvote;
            parameters[31].Value = model.monthvote;
            parameters[32].Value = model.allvote;
            parameters[33].Value = model.vipvotetime;
            parameters[34].Value = model.vipvotenow;
            parameters[35].Value = model.vipvotepreview;
            parameters[36].Value = model.goodnum;
            parameters[37].Value = model.badnum;
            parameters[38].Value = model.toptime;
            parameters[39].Value = model.saleprice;
            parameters[40].Value = model.salenum;
            parameters[41].Value = model.totalcost;
            parameters[42].Value = model.articletype;
            parameters[43].Value = model.permission;
            parameters[44].Value = model.firstflag;
            parameters[45].Value = model.fullflag;
            parameters[46].Value = model.imgflag;
            parameters[47].Value = model.power;
            parameters[48].Value = model.display;
            parameters[49].Value = model.articleid;
            return MySqlHelper.ExecuteNonQuery(Connection, System.Data.CommandType.Text, strSql.ToString(), parameters) >= 0;
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int articleid)
        {
            var strSql = new StringBuilder();
            strSql.Append("delete from jieqi_article_article ");
            strSql.Append(" where articleid=?articleid");
            MySqlParameter[] parameters = {
					new MySqlParameter("?articleid", MySqlDbType.Int32)
			};
            parameters[0].Value = articleid;
            return MySqlHelper.ExecuteNonQuery(Connection, System.Data.CommandType.Text, strSql.ToString(), parameters) >= 0;
        }

        /// <summary>
        /// 获取单个实例
        /// </summary>
        /// <param name="articleid"></param>
        /// <returns></returns>
        public ArticleInfo Get(int articleid)
        {
            var strSql = new StringBuilder();
            strSql.Append("select articleid,siteid,postdate,lastupdate,articlename,keywords,initial,authorid,author,posterid,poster,agentid,agent,sortid,typeid,intro,notice,setting,lastvolumeid,lastvolume,lastchapterid,lastchapter,chapters,size,lastvisit,dayvisit,weekvisit,monthvisit,allvisit,lastvote,dayvote,weekvote,monthvote,allvote,vipvotetime,vipvotenow,vipvotepreview,goodnum,badnum,toptime,saleprice,salenum,totalcost,articletype,permission,firstflag,fullflag,imgflag,power,display from jieqi_article_article ");
            strSql.Append(" where articleid=?articleid");
            MySqlParameter[] parameters = {
					new MySqlParameter("?articleid", MySqlDbType.Int32)
			};
            parameters[0].Value = articleid;
            var model = new ArticleInfo();
            using (MySqlDataReader dr = MySqlHelper.ExecuteReader(Connection, System.Data.CommandType.Text, strSql.ToString(), parameters))
            {
                while (dr.Read())
                {
                    #region
                    if (dr["articleid"] != null && dr["articleid"].ToString() != "")
                    {
                        model.articleid = int.Parse(dr["articleid"].ToString());
                    }
                    if (dr["siteid"] != null && dr["siteid"].ToString() != "")
                    {
                        model.siteid = int.Parse(dr["siteid"].ToString());
                    }
                    if (dr["postdate"] != null && dr["postdate"].ToString() != "")
                    {
                        model.postdate = int.Parse(dr["postdate"].ToString());
                    }
                    if (dr["lastupdate"] != null && dr["lastupdate"].ToString() != "")
                    {
                        model.lastupdate = int.Parse(dr["lastupdate"].ToString());
                    }
                    if (dr["articlename"] != null)
                    {
                        model.articlename = dr["articlename"].ToString();
                    }
                    if (dr["keywords"] != null)
                    {
                        model.keywords = dr["keywords"].ToString();
                    }
                    if (dr["initial"] != null)
                    {
                        model.initial = dr["initial"].ToString();
                    }
                    if (dr["authorid"] != null && dr["authorid"].ToString() != "")
                    {
                        model.authorid = int.Parse(dr["authorid"].ToString());
                    }
                    if (dr["author"] != null)
                    {
                        model.author = dr["author"].ToString();
                    }
                    if (dr["posterid"] != null && dr["posterid"].ToString() != "")
                    {
                        model.posterid = int.Parse(dr["posterid"].ToString());
                    }
                    if (dr["poster"] != null)
                    {
                        model.poster = dr["poster"].ToString();
                    }
                    if (dr["agentid"] != null && dr["agentid"].ToString() != "")
                    {
                        model.agentid = int.Parse(dr["agentid"].ToString());
                    }
                    if (dr["agent"] != null)
                    {
                        model.agent = dr["agent"].ToString();
                    }
                    if (dr["sortid"] != null && dr["sortid"].ToString() != "")
                    {
                        model.sortid = int.Parse(dr["sortid"].ToString());
                    }
                    if (dr["typeid"] != null && dr["typeid"].ToString() != "")
                    {
                        model.typeid = int.Parse(dr["typeid"].ToString());
                    }
                    if (dr["intro"] != null)
                    {
                        model.intro = dr["intro"].ToString();
                    }
                    if (dr["notice"] != null)
                    {
                        model.notice = dr["notice"].ToString();
                    }
                    if (dr["setting"] != null)
                    {
                        model.setting = dr["setting"].ToString();
                    }
                    if (dr["lastvolumeid"] != null && dr["lastvolumeid"].ToString() != "")
                    {
                        model.lastvolumeid = int.Parse(dr["lastvolumeid"].ToString());
                    }
                    if (dr["lastvolume"] != null)
                    {
                        model.lastvolume = dr["lastvolume"].ToString();
                    }
                    if (dr["lastchapterid"] != null && dr["lastchapterid"].ToString() != "")
                    {
                        model.lastchapterid = int.Parse(dr["lastchapterid"].ToString());
                    }
                    if (dr["lastchapter"] != null)
                    {
                        model.lastchapter = dr["lastchapter"].ToString();
                    }
                    if (dr["chapters"] != null && dr["chapters"].ToString() != "")
                    {
                        model.chapters = int.Parse(dr["chapters"].ToString());
                    }
                    if (dr["size"] != null && dr["size"].ToString() != "")
                    {
                        model.size = int.Parse(dr["size"].ToString());
                    }
                    if (dr["lastvisit"] != null && dr["lastvisit"].ToString() != "")
                    {
                        model.lastvisit = int.Parse(dr["lastvisit"].ToString());
                    }
                    if (dr["dayvisit"] != null && dr["dayvisit"].ToString() != "")
                    {
                        model.dayvisit = int.Parse(dr["dayvisit"].ToString());
                    }
                    if (dr["weekvisit"] != null && dr["weekvisit"].ToString() != "")
                    {
                        model.weekvisit = int.Parse(dr["weekvisit"].ToString());
                    }
                    if (dr["monthvisit"] != null && dr["monthvisit"].ToString() != "")
                    {
                        model.monthvisit = int.Parse(dr["monthvisit"].ToString());
                    }
                    if (dr["allvisit"] != null && dr["allvisit"].ToString() != "")
                    {
                        model.allvisit = int.Parse(dr["allvisit"].ToString());
                    }
                    if (dr["lastvote"] != null && dr["lastvote"].ToString() != "")
                    {
                        model.lastvote = int.Parse(dr["lastvote"].ToString());
                    }
                    if (dr["dayvote"] != null && dr["dayvote"].ToString() != "")
                    {
                        model.dayvote = int.Parse(dr["dayvote"].ToString());
                    }
                    if (dr["weekvote"] != null && dr["weekvote"].ToString() != "")
                    {
                        model.weekvote = int.Parse(dr["weekvote"].ToString());
                    }
                    if (dr["monthvote"] != null && dr["monthvote"].ToString() != "")
                    {
                        model.monthvote = int.Parse(dr["monthvote"].ToString());
                    }
                    if (dr["allvote"] != null && dr["allvote"].ToString() != "")
                    {
                        model.allvote = int.Parse(dr["allvote"].ToString());
                    }
                    if (dr["vipvotetime"] != null && dr["vipvotetime"].ToString() != "")
                    {
                        model.vipvotetime = int.Parse(dr["vipvotetime"].ToString());
                    }
                    if (dr["vipvotenow"] != null && dr["vipvotenow"].ToString() != "")
                    {
                        model.vipvotenow = int.Parse(dr["vipvotenow"].ToString());
                    }
                    if (dr["vipvotepreview"] != null && dr["vipvotepreview"].ToString() != "")
                    {
                        model.vipvotepreview = int.Parse(dr["vipvotepreview"].ToString());
                    }
                    if (dr["goodnum"] != null && dr["goodnum"].ToString() != "")
                    {
                        model.goodnum = int.Parse(dr["goodnum"].ToString());
                    }
                    if (dr["badnum"] != null && dr["badnum"].ToString() != "")
                    {
                        model.badnum = int.Parse(dr["badnum"].ToString());
                    }
                    if (dr["toptime"] != null && dr["toptime"].ToString() != "")
                    {
                        model.toptime = int.Parse(dr["toptime"].ToString());
                    }
                    if (dr["saleprice"] != null && dr["saleprice"].ToString() != "")
                    {
                        model.saleprice = int.Parse(dr["saleprice"].ToString());
                    }
                    if (dr["salenum"] != null && dr["salenum"].ToString() != "")
                    {
                        model.salenum = int.Parse(dr["salenum"].ToString());
                    }
                    if (dr["totalcost"] != null && dr["totalcost"].ToString() != "")
                    {
                        model.totalcost = int.Parse(dr["totalcost"].ToString());
                    }
                    if (dr["articletype"] != null && dr["articletype"].ToString() != "")
                    {
                        model.articletype = int.Parse(dr["articletype"].ToString());
                    }
                    if (dr["permission"] != null && dr["permission"].ToString() != "")
                    {
                        model.permission = int.Parse(dr["permission"].ToString());
                    }
                    if (dr["firstflag"] != null && dr["firstflag"].ToString() != "")
                    {
                        model.firstflag = int.Parse(dr["firstflag"].ToString());
                    }
                    if (dr["fullflag"] != null && dr["fullflag"].ToString() != "")
                    {
                        model.fullflag = int.Parse(dr["fullflag"].ToString());
                    }
                    if (dr["imgflag"] != null && dr["imgflag"].ToString() != "")
                    {
                        model.imgflag = int.Parse(dr["imgflag"].ToString());
                    }
                    if (dr["power"] != null && dr["power"].ToString() != "")
                    {
                        model.power = int.Parse(dr["power"].ToString());
                    }
                    if (dr["display"] != null && dr["display"].ToString() != "")
                    {
                        model.display = int.Parse(dr["display"].ToString());
                    }
                    #endregion
                }

            }
            return model;
        }

        public IList<ArticleInfo> GetListByCondition(string condition)
        {
            var strSql = new StringBuilder();
            strSql.Append("select articleid,siteid,postdate,lastupdate,articlename,keywords,initial,authorid,author,posterid,poster,agentid,agent,sortid,typeid,intro,notice,setting,lastvolumeid,lastvolume,lastchapterid,lastchapter,chapters,size,lastvisit,dayvisit,weekvisit,monthvisit,allvisit,lastvote,dayvote,weekvote,monthvote,allvote,vipvotetime,vipvotenow,vipvotepreview,goodnum,badnum,toptime,saleprice,salenum,totalcost,articletype,permission,firstflag,fullflag,imgflag,power,display from jieqi_article_article ");
            strSql.Append(" where 1=1 ");
            strSql.Append(condition);
            IList<ArticleInfo> list = new List<ArticleInfo>();
            using (MySqlDataReader dr = MySqlHelper.ExecuteReader(Connection, System.Data.CommandType.Text, strSql.ToString(), null))
            {
                while (dr.Read())
                {
                    var model = new ArticleInfo();
                    #region

                    if (dr["articleid"] != null && dr["articleid"].ToString() != "")
                    {
                        model.articleid = int.Parse(dr["articleid"].ToString());
                    }
                    if (dr["siteid"] != null && dr["siteid"].ToString() != "")
                    {
                        model.siteid = int.Parse(dr["siteid"].ToString());
                    }
                    if (dr["postdate"] != null && dr["postdate"].ToString() != "")
                    {
                        model.postdate = int.Parse(dr["postdate"].ToString());
                    }
                    if (dr["lastupdate"] != null && dr["lastupdate"].ToString() != "")
                    {
                        model.lastupdate = int.Parse(dr["lastupdate"].ToString());
                    }
                    if (dr["articlename"] != null)
                    {
                        model.articlename = dr["articlename"].ToString();
                    }
                    if (dr["keywords"] != null)
                    {
                        model.keywords = dr["keywords"].ToString();
                    }
                    if (dr["initial"] != null)
                    {
                        model.initial = dr["initial"].ToString();
                    }
                    if (dr["authorid"] != null && dr["authorid"].ToString() != "")
                    {
                        model.authorid = int.Parse(dr["authorid"].ToString());
                    }
                    if (dr["author"] != null)
                    {
                        model.author = dr["author"].ToString();
                    }
                    if (dr["posterid"] != null && dr["posterid"].ToString() != "")
                    {
                        model.posterid = int.Parse(dr["posterid"].ToString());
                    }
                    if (dr["poster"] != null)
                    {
                        model.poster = dr["poster"].ToString();
                    }
                    if (dr["agentid"] != null && dr["agentid"].ToString() != "")
                    {
                        model.agentid = int.Parse(dr["agentid"].ToString());
                    }
                    if (dr["agent"] != null)
                    {
                        model.agent = dr["agent"].ToString();
                    }
                    if (dr["sortid"] != null && dr["sortid"].ToString() != "")
                    {
                        model.sortid = int.Parse(dr["sortid"].ToString());
                    }
                    if (dr["typeid"] != null && dr["typeid"].ToString() != "")
                    {
                        model.typeid = int.Parse(dr["typeid"].ToString());
                    }
                    if (dr["intro"] != null)
                    {
                        model.intro = dr["intro"].ToString();
                    }
                    if (dr["notice"] != null)
                    {
                        model.notice = dr["notice"].ToString();
                    }
                    if (dr["setting"] != null)
                    {
                        model.setting = dr["setting"].ToString();
                    }
                    if (dr["lastvolumeid"] != null && dr["lastvolumeid"].ToString() != "")
                    {
                        model.lastvolumeid = int.Parse(dr["lastvolumeid"].ToString());
                    }
                    if (dr["lastvolume"] != null)
                    {
                        model.lastvolume = dr["lastvolume"].ToString();
                    }
                    if (dr["lastchapterid"] != null && dr["lastchapterid"].ToString() != "")
                    {
                        model.lastchapterid = int.Parse(dr["lastchapterid"].ToString());
                    }
                    if (dr["lastchapter"] != null)
                    {
                        model.lastchapter = dr["lastchapter"].ToString();
                    }
                    if (dr["chapters"] != null && dr["chapters"].ToString() != "")
                    {
                        model.chapters = int.Parse(dr["chapters"].ToString());
                    }
                    if (dr["size"] != null && dr["size"].ToString() != "")
                    {
                        model.size = int.Parse(dr["size"].ToString());
                    }
                    if (dr["lastvisit"] != null && dr["lastvisit"].ToString() != "")
                    {
                        model.lastvisit = int.Parse(dr["lastvisit"].ToString());
                    }
                    if (dr["dayvisit"] != null && dr["dayvisit"].ToString() != "")
                    {
                        model.dayvisit = int.Parse(dr["dayvisit"].ToString());
                    }
                    if (dr["weekvisit"] != null && dr["weekvisit"].ToString() != "")
                    {
                        model.weekvisit = int.Parse(dr["weekvisit"].ToString());
                    }
                    if (dr["monthvisit"] != null && dr["monthvisit"].ToString() != "")
                    {
                        model.monthvisit = int.Parse(dr["monthvisit"].ToString());
                    }
                    if (dr["allvisit"] != null && dr["allvisit"].ToString() != "")
                    {
                        model.allvisit = int.Parse(dr["allvisit"].ToString());
                    }
                    if (dr["lastvote"] != null && dr["lastvote"].ToString() != "")
                    {
                        model.lastvote = int.Parse(dr["lastvote"].ToString());
                    }
                    if (dr["dayvote"] != null && dr["dayvote"].ToString() != "")
                    {
                        model.dayvote = int.Parse(dr["dayvote"].ToString());
                    }
                    if (dr["weekvote"] != null && dr["weekvote"].ToString() != "")
                    {
                        model.weekvote = int.Parse(dr["weekvote"].ToString());
                    }
                    if (dr["monthvote"] != null && dr["monthvote"].ToString() != "")
                    {
                        model.monthvote = int.Parse(dr["monthvote"].ToString());
                    }
                    if (dr["allvote"] != null && dr["allvote"].ToString() != "")
                    {
                        model.allvote = int.Parse(dr["allvote"].ToString());
                    }
                    if (dr["vipvotetime"] != null && dr["vipvotetime"].ToString() != "")
                    {
                        model.vipvotetime = int.Parse(dr["vipvotetime"].ToString());
                    }
                    if (dr["vipvotenow"] != null && dr["vipvotenow"].ToString() != "")
                    {
                        model.vipvotenow = int.Parse(dr["vipvotenow"].ToString());
                    }
                    if (dr["vipvotepreview"] != null && dr["vipvotepreview"].ToString() != "")
                    {
                        model.vipvotepreview = int.Parse(dr["vipvotepreview"].ToString());
                    }
                    if (dr["goodnum"] != null && dr["goodnum"].ToString() != "")
                    {
                        model.goodnum = int.Parse(dr["goodnum"].ToString());
                    }
                    if (dr["badnum"] != null && dr["badnum"].ToString() != "")
                    {
                        model.badnum = int.Parse(dr["badnum"].ToString());
                    }
                    if (dr["toptime"] != null && dr["toptime"].ToString() != "")
                    {
                        model.toptime = int.Parse(dr["toptime"].ToString());
                    }
                    if (dr["saleprice"] != null && dr["saleprice"].ToString() != "")
                    {
                        model.saleprice = int.Parse(dr["saleprice"].ToString());
                    }
                    if (dr["salenum"] != null && dr["salenum"].ToString() != "")
                    {
                        model.salenum = int.Parse(dr["salenum"].ToString());
                    }
                    if (dr["totalcost"] != null && dr["totalcost"].ToString() != "")
                    {
                        model.totalcost = int.Parse(dr["totalcost"].ToString());
                    }
                    if (dr["articletype"] != null && dr["articletype"].ToString() != "")
                    {
                        model.articletype = int.Parse(dr["articletype"].ToString());
                    }
                    if (dr["permission"] != null && dr["permission"].ToString() != "")
                    {
                        model.permission = int.Parse(dr["permission"].ToString());
                    }
                    if (dr["firstflag"] != null && dr["firstflag"].ToString() != "")
                    {
                        model.firstflag = int.Parse(dr["firstflag"].ToString());
                    }
                    if (dr["fullflag"] != null && dr["fullflag"].ToString() != "")
                    {
                        model.fullflag = int.Parse(dr["fullflag"].ToString());
                    }
                    if (dr["imgflag"] != null && dr["imgflag"].ToString() != "")
                    {
                        model.imgflag = int.Parse(dr["imgflag"].ToString());
                    }
                    if (dr["power"] != null && dr["power"].ToString() != "")
                    {
                        model.power = int.Parse(dr["power"].ToString());
                    }
                    if (dr["display"] != null && dr["display"].ToString() != "")
                    {
                        model.display = int.Parse(dr["display"].ToString());
                    }

                    #endregion
                    list.Add(model);
                }
            }
            return list;
        }

        public ArticleInfo GetByName(string articlename)
        {
            var strSql = new StringBuilder();
            strSql.Append("select articleid,siteid,postdate,lastupdate,articlename,keywords,initial,authorid,author,posterid,poster,agentid,agent,sortid,typeid,intro,notice,setting,lastvolumeid,lastvolume,lastchapterid,lastchapter,chapters,size,lastvisit,dayvisit,weekvisit,monthvisit,allvisit,lastvote,dayvote,weekvote,monthvote,allvote,vipvotetime,vipvotenow,vipvotepreview,goodnum,badnum,toptime,saleprice,salenum,totalcost,articletype,permission,firstflag,fullflag,imgflag,power,display from jieqi_article_article ");
            strSql.Append(" where articlename=?articlename");
            MySqlParameter[] parameters = {
					new MySqlParameter("?articlename", MySqlDbType.String)
			};
            parameters[0].Value = articlename;
            var model = new ArticleInfo();
            using (MySqlDataReader dr = MySqlHelper.ExecuteReader(Connection, System.Data.CommandType.Text, strSql.ToString(), parameters))
            {
                while (dr.Read())
                {
                    #region
                    if (dr["articleid"] != null && dr["articleid"].ToString() != "")
                    {
                        model.articleid = int.Parse(dr["articleid"].ToString());
                    }
                    if (dr["siteid"] != null && dr["siteid"].ToString() != "")
                    {
                        model.siteid = int.Parse(dr["siteid"].ToString());
                    }
                    if (dr["postdate"] != null && dr["postdate"].ToString() != "")
                    {
                        model.postdate = int.Parse(dr["postdate"].ToString());
                    }
                    if (dr["lastupdate"] != null && dr["lastupdate"].ToString() != "")
                    {
                        model.lastupdate = int.Parse(dr["lastupdate"].ToString());
                    }
                    if (dr["articlename"] != null)
                    {
                        model.articlename = dr["articlename"].ToString();
                    }
                    if (dr["keywords"] != null)
                    {
                        model.keywords = dr["keywords"].ToString();
                    }
                    if (dr["initial"] != null)
                    {
                        model.initial = dr["initial"].ToString();
                    }
                    if (dr["authorid"] != null && dr["authorid"].ToString() != "")
                    {
                        model.authorid = int.Parse(dr["authorid"].ToString());
                    }
                    if (dr["author"] != null)
                    {
                        model.author = dr["author"].ToString();
                    }
                    if (dr["posterid"] != null && dr["posterid"].ToString() != "")
                    {
                        model.posterid = int.Parse(dr["posterid"].ToString());
                    }
                    if (dr["poster"] != null)
                    {
                        model.poster = dr["poster"].ToString();
                    }
                    if (dr["agentid"] != null && dr["agentid"].ToString() != "")
                    {
                        model.agentid = int.Parse(dr["agentid"].ToString());
                    }
                    if (dr["agent"] != null)
                    {
                        model.agent = dr["agent"].ToString();
                    }
                    if (dr["sortid"] != null && dr["sortid"].ToString() != "")
                    {
                        model.sortid = int.Parse(dr["sortid"].ToString());
                    }
                    if (dr["typeid"] != null && dr["typeid"].ToString() != "")
                    {
                        model.typeid = int.Parse(dr["typeid"].ToString());
                    }
                    if (dr["intro"] != null)
                    {
                        model.intro = dr["intro"].ToString();
                    }
                    if (dr["notice"] != null)
                    {
                        model.notice = dr["notice"].ToString();
                    }
                    if (dr["setting"] != null)
                    {
                        model.setting = dr["setting"].ToString();
                    }
                    if (dr["lastvolumeid"] != null && dr["lastvolumeid"].ToString() != "")
                    {
                        model.lastvolumeid = int.Parse(dr["lastvolumeid"].ToString());
                    }
                    if (dr["lastvolume"] != null)
                    {
                        model.lastvolume = dr["lastvolume"].ToString();
                    }
                    if (dr["lastchapterid"] != null && dr["lastchapterid"].ToString() != "")
                    {
                        model.lastchapterid = int.Parse(dr["lastchapterid"].ToString());
                    }
                    if (dr["lastchapter"] != null)
                    {
                        model.lastchapter = dr["lastchapter"].ToString();
                    }
                    if (dr["chapters"] != null && dr["chapters"].ToString() != "")
                    {
                        model.chapters = int.Parse(dr["chapters"].ToString());
                    }
                    if (dr["size"] != null && dr["size"].ToString() != "")
                    {
                        model.size = int.Parse(dr["size"].ToString());
                    }
                    if (dr["lastvisit"] != null && dr["lastvisit"].ToString() != "")
                    {
                        model.lastvisit = int.Parse(dr["lastvisit"].ToString());
                    }
                    if (dr["dayvisit"] != null && dr["dayvisit"].ToString() != "")
                    {
                        model.dayvisit = int.Parse(dr["dayvisit"].ToString());
                    }
                    if (dr["weekvisit"] != null && dr["weekvisit"].ToString() != "")
                    {
                        model.weekvisit = int.Parse(dr["weekvisit"].ToString());
                    }
                    if (dr["monthvisit"] != null && dr["monthvisit"].ToString() != "")
                    {
                        model.monthvisit = int.Parse(dr["monthvisit"].ToString());
                    }
                    if (dr["allvisit"] != null && dr["allvisit"].ToString() != "")
                    {
                        model.allvisit = int.Parse(dr["allvisit"].ToString());
                    }
                    if (dr["lastvote"] != null && dr["lastvote"].ToString() != "")
                    {
                        model.lastvote = int.Parse(dr["lastvote"].ToString());
                    }
                    if (dr["dayvote"] != null && dr["dayvote"].ToString() != "")
                    {
                        model.dayvote = int.Parse(dr["dayvote"].ToString());
                    }
                    if (dr["weekvote"] != null && dr["weekvote"].ToString() != "")
                    {
                        model.weekvote = int.Parse(dr["weekvote"].ToString());
                    }
                    if (dr["monthvote"] != null && dr["monthvote"].ToString() != "")
                    {
                        model.monthvote = int.Parse(dr["monthvote"].ToString());
                    }
                    if (dr["allvote"] != null && dr["allvote"].ToString() != "")
                    {
                        model.allvote = int.Parse(dr["allvote"].ToString());
                    }
                    if (dr["vipvotetime"] != null && dr["vipvotetime"].ToString() != "")
                    {
                        model.vipvotetime = int.Parse(dr["vipvotetime"].ToString());
                    }
                    if (dr["vipvotenow"] != null && dr["vipvotenow"].ToString() != "")
                    {
                        model.vipvotenow = int.Parse(dr["vipvotenow"].ToString());
                    }
                    if (dr["vipvotepreview"] != null && dr["vipvotepreview"].ToString() != "")
                    {
                        model.vipvotepreview = int.Parse(dr["vipvotepreview"].ToString());
                    }
                    if (dr["goodnum"] != null && dr["goodnum"].ToString() != "")
                    {
                        model.goodnum = int.Parse(dr["goodnum"].ToString());
                    }
                    if (dr["badnum"] != null && dr["badnum"].ToString() != "")
                    {
                        model.badnum = int.Parse(dr["badnum"].ToString());
                    }
                    if (dr["toptime"] != null && dr["toptime"].ToString() != "")
                    {
                        model.toptime = int.Parse(dr["toptime"].ToString());
                    }
                    if (dr["saleprice"] != null && dr["saleprice"].ToString() != "")
                    {
                        model.saleprice = int.Parse(dr["saleprice"].ToString());
                    }
                    if (dr["salenum"] != null && dr["salenum"].ToString() != "")
                    {
                        model.salenum = int.Parse(dr["salenum"].ToString());
                    }
                    if (dr["totalcost"] != null && dr["totalcost"].ToString() != "")
                    {
                        model.totalcost = int.Parse(dr["totalcost"].ToString());
                    }
                    if (dr["articletype"] != null && dr["articletype"].ToString() != "")
                    {
                        model.articletype = int.Parse(dr["articletype"].ToString());
                    }
                    if (dr["permission"] != null && dr["permission"].ToString() != "")
                    {
                        model.permission = int.Parse(dr["permission"].ToString());
                    }
                    if (dr["firstflag"] != null && dr["firstflag"].ToString() != "")
                    {
                        model.firstflag = int.Parse(dr["firstflag"].ToString());
                    }
                    if (dr["fullflag"] != null && dr["fullflag"].ToString() != "")
                    {
                        model.fullflag = int.Parse(dr["fullflag"].ToString());
                    }
                    if (dr["imgflag"] != null && dr["imgflag"].ToString() != "")
                    {
                        model.imgflag = int.Parse(dr["imgflag"].ToString());
                    }
                    if (dr["power"] != null && dr["power"].ToString() != "")
                    {
                        model.power = int.Parse(dr["power"].ToString());
                    }
                    if (dr["display"] != null && dr["display"].ToString() != "")
                    {
                        model.display = int.Parse(dr["display"].ToString());
                    }
                    #endregion
                }
            }
            return model;
        }

        /// <summary>
        /// 根据更新时间获取列表
        /// </summary>
        /// <param name="updateTime"></param>
        /// <returns></returns>
        public IList<ArticleInfo> GetListByUpdateTime(string updateTime)
        {
            var strSql = new StringBuilder();
            strSql.Append("select articleid,siteid,postdate,lastupdate,articlename,keywords,initial,authorid,author,posterid,poster,agentid,agent,sortid,typeid,intro,notice,setting,lastvolumeid,lastvolume,lastchapterid,lastchapter,chapters,size,lastvisit,dayvisit,weekvisit,monthvisit,allvisit,lastvote,dayvote,weekvote,monthvote,allvote,vipvotetime,vipvotenow,vipvotepreview,goodnum,badnum,toptime,saleprice,salenum,totalcost,articletype,permission,firstflag,fullflag,imgflag,power,display from jieqi_article_article ");
            strSql.Append(" where lastupdate > ?updateTime order by lastupdate");
            MySqlParameter[] parameters = {
					new MySqlParameter("?updateTime", MySqlDbType.String)
			};
            parameters[0].Value = updateTime;
            IList<ArticleInfo> list = new List<Model.ArticleInfo>();
            using (MySqlDataReader dr = MySqlHelper.ExecuteReader(Connection, System.Data.CommandType.Text, strSql.ToString(), parameters))
            {
                var model = new ArticleInfo();
                while (dr.Read())
                {
                    #region
                    if (dr["articleid"] != null && dr["articleid"].ToString() != "")
                    {
                        model.articleid = int.Parse(dr["articleid"].ToString());
                    }
                    if (dr["siteid"] != null && dr["siteid"].ToString() != "")
                    {
                        model.siteid = int.Parse(dr["siteid"].ToString());
                    }
                    if (dr["postdate"] != null && dr["postdate"].ToString() != "")
                    {
                        model.postdate = int.Parse(dr["postdate"].ToString());
                    }
                    if (dr["lastupdate"] != null && dr["lastupdate"].ToString() != "")
                    {
                        model.lastupdate = int.Parse(dr["lastupdate"].ToString());
                    }
                    if (dr["articlename"] != null)
                    {
                        model.articlename = dr["articlename"].ToString();
                    }
                    if (dr["keywords"] != null)
                    {
                        model.keywords = dr["keywords"].ToString();
                    }
                    if (dr["initial"] != null)
                    {
                        model.initial = dr["initial"].ToString();
                    }
                    if (dr["authorid"] != null && dr["authorid"].ToString() != "")
                    {
                        model.authorid = int.Parse(dr["authorid"].ToString());
                    }
                    if (dr["author"] != null)
                    {
                        model.author = dr["author"].ToString();
                    }
                    if (dr["posterid"] != null && dr["posterid"].ToString() != "")
                    {
                        model.posterid = int.Parse(dr["posterid"].ToString());
                    }
                    if (dr["poster"] != null)
                    {
                        model.poster = dr["poster"].ToString();
                    }
                    if (dr["agentid"] != null && dr["agentid"].ToString() != "")
                    {
                        model.agentid = int.Parse(dr["agentid"].ToString());
                    }
                    if (dr["agent"] != null)
                    {
                        model.agent = dr["agent"].ToString();
                    }
                    if (dr["sortid"] != null && dr["sortid"].ToString() != "")
                    {
                        model.sortid = int.Parse(dr["sortid"].ToString());
                    }
                    if (dr["typeid"] != null && dr["typeid"].ToString() != "")
                    {
                        model.typeid = int.Parse(dr["typeid"].ToString());
                    }
                    if (dr["intro"] != null)
                    {
                        model.intro = dr["intro"].ToString();
                    }
                    if (dr["notice"] != null)
                    {
                        model.notice = dr["notice"].ToString();
                    }
                    if (dr["setting"] != null)
                    {
                        model.setting = dr["setting"].ToString();
                    }
                    if (dr["lastvolumeid"] != null && dr["lastvolumeid"].ToString() != "")
                    {
                        model.lastvolumeid = int.Parse(dr["lastvolumeid"].ToString());
                    }
                    if (dr["lastvolume"] != null)
                    {
                        model.lastvolume = dr["lastvolume"].ToString();
                    }
                    if (dr["lastchapterid"] != null && dr["lastchapterid"].ToString() != "")
                    {
                        model.lastchapterid = int.Parse(dr["lastchapterid"].ToString());
                    }
                    if (dr["lastchapter"] != null)
                    {
                        model.lastchapter = dr["lastchapter"].ToString();
                    }
                    if (dr["chapters"] != null && dr["chapters"].ToString() != "")
                    {
                        model.chapters = int.Parse(dr["chapters"].ToString());
                    }
                    if (dr["size"] != null && dr["size"].ToString() != "")
                    {
                        model.size = int.Parse(dr["size"].ToString());
                    }
                    if (dr["lastvisit"] != null && dr["lastvisit"].ToString() != "")
                    {
                        model.lastvisit = int.Parse(dr["lastvisit"].ToString());
                    }
                    if (dr["dayvisit"] != null && dr["dayvisit"].ToString() != "")
                    {
                        model.dayvisit = int.Parse(dr["dayvisit"].ToString());
                    }
                    if (dr["weekvisit"] != null && dr["weekvisit"].ToString() != "")
                    {
                        model.weekvisit = int.Parse(dr["weekvisit"].ToString());
                    }
                    if (dr["monthvisit"] != null && dr["monthvisit"].ToString() != "")
                    {
                        model.monthvisit = int.Parse(dr["monthvisit"].ToString());
                    }
                    if (dr["allvisit"] != null && dr["allvisit"].ToString() != "")
                    {
                        model.allvisit = int.Parse(dr["allvisit"].ToString());
                    }
                    if (dr["lastvote"] != null && dr["lastvote"].ToString() != "")
                    {
                        model.lastvote = int.Parse(dr["lastvote"].ToString());
                    }
                    if (dr["dayvote"] != null && dr["dayvote"].ToString() != "")
                    {
                        model.dayvote = int.Parse(dr["dayvote"].ToString());
                    }
                    if (dr["weekvote"] != null && dr["weekvote"].ToString() != "")
                    {
                        model.weekvote = int.Parse(dr["weekvote"].ToString());
                    }
                    if (dr["monthvote"] != null && dr["monthvote"].ToString() != "")
                    {
                        model.monthvote = int.Parse(dr["monthvote"].ToString());
                    }
                    if (dr["allvote"] != null && dr["allvote"].ToString() != "")
                    {
                        model.allvote = int.Parse(dr["allvote"].ToString());
                    }
                    if (dr["vipvotetime"] != null && dr["vipvotetime"].ToString() != "")
                    {
                        model.vipvotetime = int.Parse(dr["vipvotetime"].ToString());
                    }
                    if (dr["vipvotenow"] != null && dr["vipvotenow"].ToString() != "")
                    {
                        model.vipvotenow = int.Parse(dr["vipvotenow"].ToString());
                    }
                    if (dr["vipvotepreview"] != null && dr["vipvotepreview"].ToString() != "")
                    {
                        model.vipvotepreview = int.Parse(dr["vipvotepreview"].ToString());
                    }
                    if (dr["goodnum"] != null && dr["goodnum"].ToString() != "")
                    {
                        model.goodnum = int.Parse(dr["goodnum"].ToString());
                    }
                    if (dr["badnum"] != null && dr["badnum"].ToString() != "")
                    {
                        model.badnum = int.Parse(dr["badnum"].ToString());
                    }
                    if (dr["toptime"] != null && dr["toptime"].ToString() != "")
                    {
                        model.toptime = int.Parse(dr["toptime"].ToString());
                    }
                    if (dr["saleprice"] != null && dr["saleprice"].ToString() != "")
                    {
                        model.saleprice = int.Parse(dr["saleprice"].ToString());
                    }
                    if (dr["salenum"] != null && dr["salenum"].ToString() != "")
                    {
                        model.salenum = int.Parse(dr["salenum"].ToString());
                    }
                    if (dr["totalcost"] != null && dr["totalcost"].ToString() != "")
                    {
                        model.totalcost = int.Parse(dr["totalcost"].ToString());
                    }
                    if (dr["articletype"] != null && dr["articletype"].ToString() != "")
                    {
                        model.articletype = int.Parse(dr["articletype"].ToString());
                    }
                    if (dr["permission"] != null && dr["permission"].ToString() != "")
                    {
                        model.permission = int.Parse(dr["permission"].ToString());
                    }
                    if (dr["firstflag"] != null && dr["firstflag"].ToString() != "")
                    {
                        model.firstflag = int.Parse(dr["firstflag"].ToString());
                    }
                    if (dr["fullflag"] != null && dr["fullflag"].ToString() != "")
                    {
                        model.fullflag = int.Parse(dr["fullflag"].ToString());
                    }
                    if (dr["imgflag"] != null && dr["imgflag"].ToString() != "")
                    {
                        model.imgflag = int.Parse(dr["imgflag"].ToString());
                    }
                    if (dr["power"] != null && dr["power"].ToString() != "")
                    {
                        model.power = int.Parse(dr["power"].ToString());
                    }
                    if (dr["display"] != null && dr["display"].ToString() != "")
                    {
                        model.display = int.Parse(dr["display"].ToString());
                    }
                    #endregion
                }
                list.Add(model);
            }
            return list;
        }

        /// <summary>
        /// 获取最大ARTICLE ID
        /// </summary>
        /// <returns></returns>
        public Int32 GetArticleMaxID()
        {
            var strSql = new StringBuilder();
            strSql.Append("select max(articleid) as  articleid from jieqi_article_article");
            using (MySqlDataReader dr = MySqlHelper.ExecuteReader(Connection, System.Data.CommandType.Text, strSql.ToString(), null))
            {
                while (dr.Read())
                {
                    if (!string.IsNullOrEmpty(dr[0].ToString()))
                    {
                        return Int32.Parse(dr[0].ToString());
                    }
                }
            }
            return 0;
        }
    }
}
